﻿namespace SourceCodeRepository.Web.Views.ViewData
{
    using System;

    /// <summary>
    /// Language View Data class
    /// </summary>
    public class LanguageViewData : IViewData, IEquatable<LanguageViewData>
    {
        /// <summary>
        /// Gets or sets the id of the domain object.
        /// </summary>
        /// <value>The id of the domain object.</value>
        public virtual int Id { get; set; }

        /// <summary>
        /// Gets or sets the description.
        /// </summary>
        /// <value>The description.</value>
        public virtual string Description { get; set; }

        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>
        /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
        /// </returns>
        public bool Equals(LanguageViewData other)
        {
            if (this == other)
            {
                return true;
            }

            if (this.Id == other.Id)
            {
                if (this.Description == other.Description)
                {
                    return true;
                }
                return false;
            }
            return false;
        }

        public override bool Equals(object obj)
        {
            return true;
        }

       

        /// <summary>
        /// Serves as a hash function for a particular type.
        /// </summary>
        /// <returns>
        /// A hash code for the current <see cref="T:System.Object"/>.
        /// </returns>
        public override int GetHashCode()
        {
            return (this.Id.GetHashCode() + this.Description.GetHashCode()) % 11;
        }
    }
}
